﻿using RadioPlaylisterDomain;
using log4net;
using System.Reflection;

using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

namespace RadioPlaylisterDataAccess
{

    public partial class radioplaylisterEntities : DbContext
    {
        private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public void SaveSong(RadioPlaylisterDomain.Track track)
        {
           
            song song = new song();
            song.album = track.Album;
            song.beatsPerMinute = track.BeatsPerMinute;
            song.disc = track.Disc;
            song.discCoount = track.DiscCount;
            song.genre = track.FirstGenre;
            song.location = track.Location;
            song.Title = track.Title;
            song.trackCount = track.TrackCount;
            song.trackNumber = track.TrackNumber;
            song.year = track.Year;
            this.songs.Add(song);
            try
            {
                this.SaveChanges();
            }
            catch (DbUpdateException e) 
            { 
                Log.Debug(e);
            }
        }
 
    }
}
